﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StudentInfoSystem.Core.Models.Enums;


// 表明下面代码都在这个命名空间里
namespace StudentInfoSystem.Core.Models;

/// <summary>
/// 表示系统中的学生实体
/// <para>
/// 此类封装了学生的基本信息，包括个人资料、学籍信息和联系方式
/// ID、Name、Gender、College、Department、Class、Dormitory、Hometown、Phone
/// </para>
/// <example>
/// 创建新学生：
/// <code>
/// var student = new Student {
///     Id = "20230001",
///     Name = "张三",
///     Gender = Gender.Male,
///     College = "计算机学院"
/// };
/// </code>
/// </example>
public class Student : ObservableObject
{
    private string _id = string.Empty;

    /// <summary>
    /// 学生的唯一学号（8位数字）
    /// </summary>
    [Required(ErrorMessage = "学号不能为空")]
    [StringLength(8, MinimumLength = 8, ErrorMessage = "学号必须是8位数字")]
    [RegularExpression(@"^\d{8}$", ErrorMessage = "学号必须由8位数字组成")]
    public string Id
    {
        get => _id;
        set => SetProperty(ref _id, value.Trim());
    }

    private string  _name = string.Empty;

    /// <summary>
    /// 学生姓名（2-4个中文字符）
    /// </summary>
    [Required(ErrorMessage = "姓名不能为空")]
    [StringLength(4, MinimumLength = 2, ErrorMessage = "姓名长度应为2-4个字符")]
    public string Name
    {
        get => _name;
        set => SetProperty(ref _name, value.Trim());
    }

    private Gender  _gender;

    /// <summary>
    /// 学生性别
    /// </summary>
    [Required]
    [Range(1, 2, ErrorMessage = "必须选择性别")]
    public Gender Gender
    {
        get => _gender;
        set => SetProperty(ref _gender, value);
    }


    private string _college = string.Empty;

    /// <summary>
    /// 所属学院名称
    /// </summary>
    public string College
    {
        get => _college;
        set => SetProperty(ref _college, value.Trim());
    }

    private string _department = string.Empty;

    /// <summary>
    /// 所属系（专业）名称
    /// </summary>
    public string Department
    {
        get => _department;
        set => SetProperty(ref _department, value);
    }

    private string _class = string.Empty;

    /// <summary>
    /// 班级名称
    /// </summary>
    public string Class
    {
        get => _class;
        set => SetProperty(ref _class, value);
    }

    private string _dormitory = string.Empty;

    /// <summary>
    /// 宿舍号（学生住宿位置）
    /// </summary>
    public string Dormitory
    {
        get => _dormitory;
        set => SetProperty(ref _dormitory, value);
    }

    private string _hometown = string.Empty;

    /// <summary>
    /// 生源地（学生籍贯）
    /// </summary>
    public string Hometown
    {
        get => _hometown;
        set => SetProperty(ref _hometown, value);
    }


    private string _phone = string.Empty;

    /// <summary>
    /// 联系电话
    /// </summary>
    public string Phone
    {
        get => _phone;
        set => SetProperty(ref _phone, value);
    }


}


